<template>
	<view class="mainCss">
		<view class="titleBox">
			<view class="titleLeft">
				<img src="../../static/title/back.png" class="titleBack" @click="goBack">
			</view>
			<view class="titleText">
				<text>钱包</text>
			</view>
			<view class="titleRight">

			</view>
		</view>
		<view class="otherBox">
			<view class="other" @click="vip">
				<img src="../../static/my/vip.png" class="otherIcon">
				<view class="otherText" style="display: flex; justify-content: space-between; align-items: center;">
					<text>余额</text>
					<text>￥{{balance}}</text>
				</view>
				<img src="../../static/home/right.png" class="otherMore">
			</view>
			<view class="other" @click="wallet">
				<img src="../../static/my/wallet.png" class="otherIcon">
				<text class="otherText">提现</text>
				<img src="../../static/home/right.png" class="otherMore">
			</view>
			<view class="other" @click="record">
				<img src="../../static/my/release.png" class="otherIcon">
				<text class="otherText">支付明细</text>
				<img src="../../static/home/right.png" class="otherMore">
			</view>
		</view>
		<view class="bodyBox">

		</view>
	</view>
</template>

<script>
	var app = getApp();
	export default {
		data() {
			return {
				balance: "0.00"
			}
		},
		onLoad() {
			this.getBalance()
		},
		methods: {
			// 返回
			goBack() {
				uni.navigateBack(0)
			},
			// 首页
			goHome() {
				uni.switchTab({
					url: '/pages/home/index',
				})
			},
			// 点击余额
			vip() {
				uni.navigateTo({
					url: `/pagesC/wallet/balance?balance=` + this.balance
				})
			},
			// 点击提现
			wallet() {
				uni.navigateTo({
					url: '/pagesC/wallet/bill'
				})
			},
			// 点击支付记录
			record() {
				uni.navigateTo({
					url: '/pagesC/vip/record'
				})
			},
			// 获取余额
			getBalance() {
				// uni.request({
				// 	header: {
				// 		'Content-Type': 'application/x-www-form-urlencoded'
				// 	},
				// 	url: 'https://ypsf.huashengzhuan.cn/Application/NewShopApi.ashx?action=getBalance',
				// 	method: 'POST',
				// 	data: {
				// 		OpenID: 'owner',
				// 	},
				// 	dataType: 'json',
				// 	success: res => {
				// 		this.balance = res.data.Balance
				// 	}
				// })
				this.$myRequest({
					url: 'getBalance',
					data: {
							OpenID: app.globalData.openID
						},
					dataType: 'json',
				}).then(res => {
					this.balance = res.data.Balance
					console.log(this.balance)
				})
			}
		}
	}
</script>

<style>
	@import '../../css/my.css';
	@import '../../css/wallet.css';
</style>
